package fms.models;
 
import java.util.List;
 
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;

import fms.classes.Form6;
 
 
public class Form6DAO {
 
    private SqlSessionFactory sqlSessionFactory;
 
    public Form6DAO(){
    	try{
    		sqlSessionFactory = MyBatisSqlConnection.getSqlSessionFactory();
    	}catch(Exception e) {
    		System.out.println("failed to get sqlSessionFactory");
    	}
    }
 
    /**Returns the list of all Form6 instances from the database*/
    @SuppressWarnings("unchecked")
    public List<Form6> selectAll(){
 
        SqlSession session = sqlSessionFactory.openSession();
 
        try {
            List<Form6> list = session.selectList("Form6.getAll");
            return list;
        } finally {
            session.close();
        }
    }
 
    /**Returns a Form6 instance from the database*/
    public Form6 selectById(int entry_no){
 
        SqlSession session = sqlSessionFactory.openSession();
 
        try {
            Form6 form6 = (Form6) session.selectOne("Form6.getById",entry_no);
            return form6;
        } finally {
            session.close();
        }
    }
 
    /**Updates an instance of Form6 in the database*/
    public void update(Form6 form6){
 
        SqlSession session = sqlSessionFactory.openSession();
 
        try {
            session.update("Form6.update", form6);
            session.commit();
        } finally {
            session.close();
        }
    }
 
    /** Insert an instance of Form6 into the database*/
    public void insert(Form6 form6){
 
        SqlSession session = sqlSessionFactory.openSession();
 
        try {
            session.insert("Form6.insert", form6);
            session.commit();
        } finally {
            session.close();
        }
    }
 
    /** Delete an instance of Form6 from the database*/
    public void delete(int entry_no){
 
        SqlSession session = sqlSessionFactory.openSession();
 
        try {
            session.delete("Form6.deleteById", entry_no);
            session.commit();
        } finally {
            session.close();
        }
    }
}